<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #show{
            background-color: orange;
            height: 30px;
            width: 30px;
            text-align: center;
        }
        #add{
            background-color: orchid;
            height: 30px;
            width: 30px;
            text-align: center;
        }
    </style>
    <script>
        function onLoad(){
            if(typeof(Storage)=='undefined'){
                alert('您的浏览器不支持');
            }else{
                show.addEventListener('click',readFromLocalStorage);
                add.addEventListener('click',addFromLocalStorage);
            }
        }
        function readFromLocalStorage(){
            window.localStorage.num=0;
            show.innerHTML=localStorage.num;
        }
        function addFromLocalStorage(){
            show.innerHTML=++localStorage.num;
        }
    </script>
</head>
<body onload="onLoad()">
<div id="show">0</div>
<div id="add">+</div>
</body>
</html>